package com.lovo;

import com.lovo.servlet.InvoiceServlet;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.startup.Tomcat;

public class ApplicationMain {
    public static void main(String[] args) throws LifecycleException {
        // 实例化Tomcat
        Tomcat tomcat = new Tomcat();        
        // 设置Tomcat端口        
         tomcat.setPort(8080);        
        // 引导HTTP引擎        
         tomcat.getConnector();        
         Context ctx = tomcat.addContext("",null);        
        // 第二个参数是Servlet名称        
         Wrapper servlet = Tomcat.addServlet(ctx,"invoiceServlet",new InvoiceServlet());
        // 启动初始化Servlet        
         servlet.setLoadOnStartup(1);        
        // 任何访问路径都能进入该Servlet        
         servlet.addMapping("/invoices");
        // 启动服务器        
         tomcat.start();
    }
}
